package com.finer.controller;

import com.finer.entity.ResponseMessage;
import com.finer.entity.document.FinerGoodUnit;
import com.finer.feign.FinerGoodUnitFeign;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 商品单位表(FinerGoodUnit)表控制层
 *
 * @author makejava
 * @since 2024-10-21 10:20:37
 */
@RestController
@RequestMapping("finerGoodUnit")
@Slf4j
@CrossOrigin
public class FinerGoodUnitController {
    /**
     * 服务对象
     */
    @Resource
    private FinerGoodUnitFeign finerGoodUnitFeign;

    /**
     * 分页查询
     *
     * @return 查询结果
     */
    @RequestMapping("queryUnitByPage")
    public ResponseMessage queryUnitByPage(@RequestParam Map map) {
        log.info("FinerGoodUnitController queryUnitByPage param:{}",map);
        return finerGoodUnitFeign.queryUnitByPage(map);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<FinerGoodUnit> queryById(@PathVariable("id") Integer id) {
        return null;
    }

    /**
     * 新增数据
     *
     * @param finerGoodUnit 实体
     * @return 新增结果
     */
    @PostMapping
    public ResponseEntity<FinerGoodUnit> add(FinerGoodUnit finerGoodUnit) {
        return null;
    }

    /**
     * 编辑数据
     *
     * @param finerGoodUnit 实体
     * @return 编辑结果
     */
    @RequestMapping("updUnit")
    public ResponseMessage updUnit(FinerGoodUnit finerGoodUnit) {
        log.info("FinerGoodUnitController updUnit param:{}",finerGoodUnit);
        ResponseMessage msg = finerGoodUnitFeign.updUnit(finerGoodUnit);
        return msg;
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @RequestMapping("delUnit")
    public ResponseMessage deleteById(Integer id) {
        log.info("FinerGoodUnitController deleteById param:{}",id);
        ResponseMessage msg = finerGoodUnitFeign.delUnitById(id);
        return msg;
    }
    @RequestMapping("addUnit")
    public ResponseMessage addUnit(@RequestBody FinerGoodUnit finerGoodUnit) {
        log.info("FinerGoodUnitController addUnit param:{}",finerGoodUnit);
        ResponseMessage msg = finerGoodUnitFeign.addUnit(finerGoodUnit);
        return msg;
    }
}

